# !/usr/bin/env python
# -*- coding: utf-8 -*-
class Func:
    # 驼峰
    @staticmethod
    def camel(s=str):
        """hello_world => HelloWorld"""
        arr = s.split("_")
        name = ""
        for item in arr:
            name += item[0].upper()
            if len(item) > 1:
                name += item[1:]
        return name

    # 驼峰
    @staticmethod
    def first_camel(s=str):
        """hello_world => helloWorld"""
        arr = s.split("_")
        name = ""
        for i in range(0, len(arr)):
            item = arr[i]
            if i == 0:
                name += item[0]
            else:
                name += item[0].upper()
            if len(item) > 1:
                name += item[1:]
        return name

    @staticmethod
    def suffix(s=str):
        index = s.rfind(".")
        if index == -1:
            return None
        return s[index + 1:]

    @staticmethod
    def name(s=str):
        start_index = s.rfind("/")
        end_index = s.rfind(".")
        if start_index == -1:
            start_index = 0
        if end_index == -1:
            end_index = len(s)
        return s[start_index + 1: end_index]

    @staticmethod
    def startswith(s=str, sub=str):
        return s.startswith(sub)
    
    @staticmethod
    def types(columns: list):
        type_list = []
        for column in columns:
            if column['type'] not in type_list:
                type_list.append(column['type'])
        return type_list